/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.db;

import com.exception.DataException;

/**
 *
 * @author Administrador
 */
public class SqlManager {
    
    public static void closeConexion(java.sql.Connection c)throws DataException{
        try{
            if(c != null) c.close();
        }catch(java.sql.SQLException e){
            System.out.println("Error! al cerrar la conexion: "+e.getMessage());
        }
    }
    
    public static void setAutoCommit(java.sql.Connection c, boolean valor)throws DataException{
        try{
            if(c != null) c.setAutoCommit(valor);
        }catch(java.sql.SQLException e){
            System.out.println("Error! al cambiar el autocommit: "+e.getMessage());
        }
    }
    
    public static void commit(java.sql.Connection c) throws DataException{
        try{
            if(c != null) c.commit();
        }catch(java.sql.SQLException e){
            System.out.println("Error! en rollBack: e = "+e.getMessage());
        }
    }
    
    public static void rollBack(java.sql.Connection c)throws DataException{
        try{
            if(c != null) c.rollback();
        }catch(java.sql.SQLException e){
            System.out.println("Error! en rollBack: e = "+e.getMessage());
        }
    }

    public static void closeRs(java.sql.ResultSet rs)throws DataException{
        try{
            if(rs != null) rs.close();
        }catch(java.sql.SQLException e){
            System.out.println("Error! al cerrar el ResultSet: "+e.getMessage());
        }
    }

    public static void closePreSt(java.sql.PreparedStatement preSt)throws DataException{
        try{
            if(preSt != null) preSt.close();
        }catch(java.sql.SQLException e){
            System.out.println("Error! al cerrar el PrepareStatement: "+e.getMessage());
        }
    }
}
